package com.sikaryofficial.backend.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sikaryofficial.backend.annotation.Repeat;
import com.sikaryofficial.backend.domain.dto.req.EvaluateReplyListReq;
import com.sikaryofficial.backend.domain.dto.req.EvaluateReplyReq;
import com.sikaryofficial.backend.domain.dto.resp.EvaluateReplyDTO;
import com.sikaryofficial.backend.manager.EvaluateReplyManager;
import com.sikaryofficial.common.core.utils.HiResultUtil;
import com.sikaryofficial.common.core.utils.PageUtil;
import com.sikaryofficial.common.core.web.controller.BaseController;
import com.sikaryofficial.common.core.web.domain.HiResult;
import com.sikaryofficial.common.core.web.domain.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 品牌口味评价回复Controller
 *
 * @author qinjinyuan
 * @date 2023-11-03
 */
@RestController
@RequestMapping("/evaluateReply")
@Api(tags = "品牌口味评价回复")
public class EvaluateReplyController extends BaseController {
    @Autowired
    private EvaluateReplyManager evaluateReplyManager;

    /**
     * 新增品牌口味评价回复
     */
    @ApiOperation("新增品牌口味评价回复")
    @PostMapping("/add")
    @Repeat
    public HiResult<EvaluateReplyDTO> add(@RequestBody EvaluateReplyReq evaluateReplyReq) {
        return HiResultUtil.success(evaluateReplyManager.saveReply(evaluateReplyReq));
    }

    /**
     * 查询品牌口味评价回复列表
     */
    @PostMapping("/listByPage")
    @ApiOperation("评价回复列表-个人中心")
    @Repeat
    public PageResult<EvaluateReplyDTO> listByPage(@Validated @RequestBody EvaluateReplyListReq req) {
        IPage<EvaluateReplyDTO> page = evaluateReplyManager.list(req);
        return PageUtil.success(page.getRecords(), page.getTotal());
    }
}
